# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# 建立者:        博智科技  
# Name:         demo1231
# Description:
# Author:       yzl
# Date:         2019-02-08
#-------------------------------------------------------------------------------


set1 = set(range(10))
print(type(set1))
# print(set1)


# 互异性 无序性
set2 = set('hello')
# print(set2)


set3 = set(['bill','john','mike','john'])
print(set3)


a = set([1,2,3])

b = set((3,5,1,7))
# 合并集合
# print(a.union(b))
# print(a | b)



# 交集
print(a.intersection(b))
print(a & b)


c = set([2,3])
# 判断集合 c 是否为 a 的子集
print(c.issubset(a))


# 判断集合 a 是否为 c 的子集
print(a.issubset(c))


d = set([1,2,3])

# 判断 a d集合是否相等
print(a == d)


# 计算集合差集
print(a.difference(b))
print(a - b)


# 计算集合对称差
print(a.symmetric_difference(b))
print(a ^ b)
print((a -b) | (b - a))


# 复制集合
x = a.copy()


# 判断集合是否相同
print(x is a)


# 向集合添加元素
x.add(30)
print(x)
print(a)


# 判断 1是否属于集合a
print(1 in a)
